<template>
  <span
    :class="['noneditable', 'ref-link', refDisabled ? 'ref-disabled' : '']"
    :contenteditable="false"
    :data-refname="bizItem.refname"
    :data-standardid="bizItem.standardId"
    :data-maincontentid="bizItem.mainContentId"
    :data-refclassification="bizItem.refclassification"
    :data-refcode="bizItem.refcode || bizItem.content"
    :data-refdate="bizItem.refdate"
    :data-docno="bizItem.docno || ''"
    :data-refversion="bizItem.refversion"
    :data-refcontent="bizItem.content"
    :data-id="bizItem.dataId"
    :data-type="bizItem.contentType"
    :data-link-url="getLinkUrl(bizItem.mainContentId) || ''"
    :data-refanchor="bizItem.refanchor"
    :data-category="bizItem.category"
    >{{ bizItem.fullContent }}</span
  >
</template>
<script>
import { getLinkUrl } from '@/utils/helpers'

export default {
  props: {
    index: {
      type: Number,
      default: 0
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  methods: { getLinkUrl },
  computed: {
    refDisabled() {
      return !this.bizItem.mainContentId || this.bizItem.mainContentId === 'null'
    },
    bizItem() {
      const item = JSON.parse(this.item.bizExtra || '{}')
      return { ...item, ...this.item }
    }
  }
}
</script>
